<?php
	
class ServiceController extends Controller
{

	public $layout='column1';

	public function actionIndex(){
		$this->render('index');		
	}

	
	public function actionEncodeHtml(){
		$model = new ServiceForm; 
		
		if(isset($_POST['ServiceForm'])){
			//$model->attributes = $_POST['ServiceForm'];
			$model->input= $_POST['ServiceForm']['input'];
			
			$model->result = htmlentities($model->input,ENT_QUOTES);
			$this->render('EncodeHtml', array('model'=>$model));
		}
		else{
			$this->render('EncodeHtml', array('model'=>$model));
		}
	}

	public function actionEncodeURL(){
		$model = new ServiceForm; 
		
		if(isset($_POST['ServiceForm'])){
			$model->input= $_POST['ServiceForm']['input'];
			
			$model->result = urlencode($model->input);
			$this->render('EncodeUrl', array('model'=>$model));
		}
		else{
			$this->render('EncodeUrl', array('model'=>$model));
		}
	}
	public function actionRegEx(){
		$model = new ServiceForm; 
		
		if(isset($_POST['ServiceForm'])){
			$model->input= $_POST['ServiceForm']['input'];
			$model->input2=$_POST['ServiceForm']['input2'];	
			//preg_match need some sort of beginning and end market : #
			$ret = preg_match('#'.$model->input.'#',$model->input2);
			if($ret == 1 ){
				$model->result = "Yeah, matching";
			}
			else{
				$model->result = "Opps, do not match";
			}	
			$this->render('RegEx', array('model'=>$model));
		}
		else{
			$this->render('RegEx', array('model'=>$model));
		}
	}


}
?>
